﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.Entities
{
    [Serializable]
    public class CriteriaTypeSix : BaseCriteria
    {
        public int MaxValue { get; set; }
        public int MinValue { get; set; }
        public Guid WeightMatrixId { get; set; }
        public List<CriteriaChartData> CriteriaData { get; set; }
        public bool IsScreenable { get; set; }
        public Guid CriteriaLevel3Id { get; set; }

        public static CriteriaTypeSix CriteriaTypeSixWithGraph(CriteriaTypeSix criteriaTypeSix, List<CriteriaChartData> criteriaData)
        {
            return new CriteriaTypeSix()
            {
                Id = criteriaTypeSix.Id,
                Name = criteriaTypeSix.Name,
                CriteriaType = CriteriaTypeEnum.CriteriaType1,
                CriteriaData = criteriaData,
                //MaxValue = (criteriaData != null && criteriaData.Count > 0) ? criteriaData.Max(d => d.XAxisValue) : 0,
                //MinValue = (criteriaData != null && criteriaData.Count > 0) ? criteriaData.Min(d => d.XAxisValue) : 0,
                MaxValue = criteriaTypeSix.MaxValue == 0? 100 : criteriaTypeSix.MaxValue,
                MinValue = criteriaTypeSix.MinValue,
                IsScreenable = criteriaTypeSix.IsScreenable
            };
        }
    }
}
